import java.math.BigInteger;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: XMQ
 * Date: 2022-06-14
 * Time: 5:41
 */
public class Test {
    public static String multiply(String num1, String num2) {
        char[] ch1 = num1.toCharArray();
        char[] ch2 = num2.toCharArray();
        BigInteger bi = BigInteger.valueOf(123124);
        return new String(String.valueOf(con(ch1) * con(ch2)));
    }
    public static int con(char[] ch){
        int sum = 0;
        if(ch.length == 1) return ch[0] - '0';
        for(int i = 0; i < ch.length; i++){
            sum += ch[i] - '0';
            if(i != ch.length-1){
                sum *= 10;
            }
        }
        return sum;
    }

    public static void main(String[] args) {
        String s1 = "1";
        String s2 = "3";
        System.out.println(Long.MAX_VALUE);
        System.out.println(multiply(s1, s2));
    }
    public static String reverseWords(String s) {
        char[] str = s.toCharArray();
        int i = 0;
        int j = 0;
        for(;j < str.length; j++){
            if(str[j] == ' '){
                reverse(str,i,j-1);
                i = j + 1;
                j = i;
            }
        }
        reverse(str,i,str.length-1);
        return  new String(str);
    }
    public static void reverse(char[] ch, int i, int j){
        while(i < j){
            char tmp = ch[i];
            ch[i] = ch[j];
            ch[j] = tmp;
            i++;
            j--;
        }
    }
    public static String reverseWords1(String s) {
        String[] str = s.split(" ");
        StringBuffer sb = new StringBuffer();
        for(int i = 0; i < str.length; i++){
            sb.append(reverse1(str[i]));
            sb.append(" ");
        }
        s = String.valueOf(sb);
        return s;
    }
    public static String reverse1(String s){
        char[] ch = s.toCharArray();

        int left = 0;
        int right = ch.length - 1;
        while(left < right){
            char tmp = ch[left];
            ch[left] = ch[right];
            ch[right] = tmp;
            left++;
            right--;
        }
        s = new String(ch);
        return s;
    }
    public static void main2(String[] args) {
        String s ="Let's take LeetCode contest";
        System.out.println(reverseWords(s));
    }
    public static void main1(String[] args) {
        char[] s = {'1','2'};
        int l1 = s[0] - '0';
        System.out.println(l1);
        String s1 = String.valueOf(s);
        String s2 = "123";
        int l = Integer.parseInt(s2);
        System.out.println(l);
        StringBuffer sb = new StringBuffer(s1);
        System.out.println(sb.reverse());
        s1 = sb.toString();
        for (int i = 0; i < s.length; i++) {
            s[i] = s1.charAt(i);
        }
        System.out.println(s);
    }
}
